const http = require('http');

const server = http.createServer(((req, res) => {
    // 模拟日志
    console.log('current time', Date.now());
    // 模拟错误
    console.error('pretending to be an error', Date.now());
    // 模拟一个错误
    if (req.url === '/err') {
        throw new Error('/err 错误');
    }

    res.setHeader('Content-type', 'application/json');
    res.end(JSON.stringify({errno: 0, msg: 'pm2 test server 2'}));
}));

server.listen(9000);
console.log('Server is listening on port 9000');